#include <iostream>
#define maxn 10000
using namespace std;
int main() {
    int stack[maxn];
    int topindex = 0;
    int optimes = 0;
    cin>>optimes;
    for (int i = 0; i<optimes; i++) {
        string op;
        int number;
        cin>>op;
        if (op == "push") {
            cin>>number;
            stack[topindex]=number;
            topindex++;
        }else if (op =="pop") {
            if (topindex!=0) {
                topindex--;
            }else {
                cout<<"Empty"<<endl;
            }
        }else if (op == "query") {
            if (topindex!=0) {
                cout<<stack[topindex-1]<<endl;
            }else {
                cout<<"Empty"<<endl;
            }
        }else if(op=="size") {
            cout<<topindex<<endl;
        }
    }
}
// 64 位输出请用 printf("%lld")